package kliment.flex.mx.controls {
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	
	import mx.controls.List;
	import mx.controls.listClasses.IListItemRenderer;
	import mx.controls.listClasses.ListItemRenderer;
	import mx.core.ClassFactory;

	public class ListExt extends List {
		public function ListExt() {
			super();
			itemRenderer = new ClassFactory(LabelExt);
		}

		override protected function mouseOverHandler(event:MouseEvent):void {
			if (itemDisable(event)) return;
			super.mouseOverHandler(event);
		}

		override protected function mouseDownHandler(event:MouseEvent):void {
			if (itemDisable(event)) return;
			super.mouseDownHandler(event);
		}

		override protected function mouseUpHandler(event:MouseEvent):void {
			if (itemDisable(event)) return;
			super.mouseUpHandler(event);
		}

		override protected function mouseClickHandler(event:MouseEvent):void {
			if (itemDisable(event)) return;
			mouseClickHandler(event);
		}

		override protected function mouseDoubleClickHandler(event:MouseEvent):void {
			if (itemDisable(event)) return;
			super.mouseDoubleClickHandler(event);
		}

		override protected function keyDownHandler(event:KeyboardEvent):void {
			event.stopPropagation();

			// Disable key down event.
			//super.keyDownHandler(event);
		}

		private function itemDisable(event:MouseEvent):Boolean {
			var item:IListItemRenderer = mouseEventToItemRenderer(event);
			if (item && item.data && ((item.data is XML && item.data.@enabled == 'false') || item.data.enabled==false || item.data.enabled=='false'))
				return true;
			return false;
		}
	}
}